home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5623 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  92 lines

  1. Path: ix.netcom.com!netnews
  2. From: judgemi@ix.netcom.com(Michael Judge )
  3. Newsgroups: comp.lang.c++
  4. Subject: ODBC/OLE/Visual C++ problem. PLEASE
  5. Date: 5 Feb 1996 23:27:48 GMT
  6. Organization: Netcom
  7. Message-ID: <4f63pk$sjf@reader2.ix.netcom.com>
  8. NNTP-Posting-Host: bos-ma9-23.ix.netcom.com
  9. X-NETCOM-Date: Mon Feb 05  3:27:48 PM PST 1996
  10.  
  11. This is for OLE/ODBC/Microsoft Visual C++ Gurus.
  12.  
  13. environment: Windows 3.X, ODBC DLLs ver 2.1
  14.  
  15. O.k. here is the problem then I will describe how to reproduce it. 
  16.     (takes 5 minutes to reproduce)
  17. When executing a SQL statement twice on a microsoft ODBC datasource, I
  18. recieve a GP fault in COMPOBJ.DLL. This ONLY happens when ODBC drivers
  19. version 2.1 have been installed. So any new machine, or old one with
  20. new software will reproduce this.  
  21.  
  22. If I replace OLE2DISP.DLL ver 2.1 with OLE2DISP.DLL ver 2.0 this
  23. problem doesnt occur. (of course there are other side affects
  24. that make this a poor solution.)
  25.  
  26. here is the kicker! This only happens when I have a 'WHERE' clause in
  27. the statement. and ONLY in RELEASE!
  28.  
  29. how to reproduce.                              
  30.  
  31. 1: AppWizard new project.
  32.     a. OLE options. (container)
  33.     b. shut off all check boxes under options. (simplifies things)
  34.     c. database support, include header files only
  35.     d. classes: change your view class to a formview class.
  36.     e. let it create all its files
  37. 2. AppStudio.
  38.     a. Add a button to your formview
  39.     b. class wizard: add a message map for bn_clicked
  40.     c. choose edit code
  41. 3. CMyFormView::OnButton1() should look like this (also add derivation
  42. of CRecordset)
  43.  
  44. class CMyRecordSet: public CRecordset
  45. {
  46. public:
  47.     CMyRecordSet(CDatabase *t_ptr);
  48.     virtual CString GetDefaultSQL(){return CString("");}
  49.     virtual void DoFieldExchange(CFieldExchange* pFX){}
  50. };
  51. CMyRecordSet::CMyRecordSet(CDatabase *t_ptr)
  52. :CRecordset(t_ptr)
  53. {
  54. }
  55.  
  56. void CMyFormView::OnButton1()
  57. {
  58.     CDatabase t_pdatabase;
  59.     t_pdatabase.Open(NULL); 
  60.     CMyRecordSet t_set(&t_pdatabase);
  61.     t_set.Open();
  62.     CString t_sqlstatement("SELECT TESTCOLUMN from TESTTABLE where
  63. TESTCOLUMN='EXAMPLE'");
  64.       ::SQLExecDirect(t_set.m_hstmt,(UCHAR
  65. FAR*)t_sqlstatement.GetBuffer(0), SQL_NTS);
  66.     t_set.Close();
  67.     t_pdatabase.Close();
  68. }
  69.  
  70. 4. change t_sqlstatement to be whatever makes sense to your database
  71. you are going after
  72. 5. build for release and execute.
  73. 6. click on button
  74. 7. choose a datasource that uses ODBCJT16.DLL (I have tried foxprow,
  75. access and paradox datasources)
  76.     note: make sure your SQL makes sense
  77. 8. let it process call then click on button again.
  78.  
  79. Thats it.  
  80. Oh yes, after this happens, it wont blow up again until you leave
  81. windows and return. 
  82. I have a VB test app that works fine with it.
  83. In debug it works
  84. replace OLE2DISP.DLL v2.1 with v2.0 it works
  85. if not an ole container it works
  86.  
  87. I am almost in tears here please help!
  88.  
  89. Email as well as post please.
  90. Email: judgemi@ix.netx.com
  91.  
  92.